const webpack = require('webpack')
const { merge } = require('webpack-merge')
const webpackCommon = require('./webpack.common.js')
module.exports = merge(webpackCommon, {
  mode: 'development',
  devtool: 'cheap-moudule-eval-source-map',
  devServer: {
    // 部分静态资源，指定额外的静态资源目录
    contentBase: './public/favicon.ico',
    proxy: {
      '/api': {
        // http://localhost:8080/api/users -> https://api.github.com/api/users
        target: 'https://api.github.com',
        pathRewrite: {
          '^/api': ''
        },
        // 不能使用 localhost:8080 作为 github 的主机名
        changeOrigin: true
      }
    },
    hot: true
    // hotOnly: true
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
})
